<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 11/26/24
 * Time: 4:42 PM
 */

namespace app\adminapi\lists\skits;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\skits\SkitsBanner;
use app\common\model\skits\SkitsFollow;
use app\common\lists\ListsSearchInterface;


/**
 * SkitsFollow列表
 * Class SkitsFollowLists
 * @package app\adminapi\lists
 */
class SkitsBannerLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author likeadmin
     * @date 2024/07/13 15:05
     */
    public function setSearch(): array
    {
        return [
            '=' => ['app_id', 'skits_id'],
        ];
    }


    /**
     * @notes 获取列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author likeadmin
     * @date 2024/07/13 15:05
     */
    public function lists(): array
    {
        return SkitsBanner::with([
            'skits' => function ($q) {
                $q->withField('id,skits_name,recommendation,thumb');
            }
        ])
            ->where($this->searchWhere)
            ->field(['id', 'app_id', 'skits_id', 'sort', 'create_time', 'update_time'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order(['sort' => 'asc'])
            ->select()
            ->toArray();
    }


    /**
     * @notes 获取数量
     * @return int
     * @author likeadmin
     * @date 2024/07/13 15:05
     */
    public function count(): int
    {
        return SkitsBanner::where($this->searchWhere)->count();
    }

}
